Skip to content

Scaladoc: new heuristic for extension method parameter extraction #14810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 5, 2023

Conversation

rochala
Copy link
Contributor

@rochala rochala commented Mar 29, 2022

Before this changes, it wouldn't generate due to incorrect extension parameters extractor functions.
It also implements new heuristic to distinct extensions and method parameters based on definition position.
Also fixed type parameter coloring by adding new css rule, to match doc style.
Based on #14321 , it should be closed after this PR is merged.

Documentation for test tests.extensionParams
image

@rochala rochala changed the title scaladoc - new heuristic for extension method parameter extraction Scaladoc: new heuristic for extension method parameter extraction Mar 29, 2022
@pikinier20 pikinier20 self-assigned this Mar 30, 2022
val method = sym.tree.asInstanceOf[DefDef]
(for {
defPosition <- method.symbol.pos
defStart <- scala.util.Try(defPosition.start).toOption
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does start here throw exceptions?

If so, I'm not sure if it's not a bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does. It fails assertions for some methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolasstucki is this intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the exception?

Does the position exist? If not, calling start should fail an assertion. It would be unexpected for the position to not
exist and I would say that is a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the assertion failure just as you said.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion fails for methods, which have position of type NoSourcePosition. These are mostly methods from inheritance such as productElementNames from Product trait. Is this a bug, as symbol.pos returns Option and logically it should return None for NoSourcePosition ?

val method = sym.tree.asInstanceOf[DefDef]
(for {
defPosition <- method.symbol.pos
defStart <- scala.util.Try(defPosition.start).toOption
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the exception?

Does the position exist? If not, calling start should fail an assertion. It would be unexpected for the position to not
exist and I would say that is a bug.

@pikinier20 pikinier20 force-pushed the extension-method-doc-new-heuristic branch from 5d5f5d4 to dbf84f5 Compare April 25, 2022 11:06
@pikinier20
Copy link
Contributor

@nicolasstucki Could you take a look at the last commit?

@nicolasstucki
Copy link
Contributor

@nicolasstucki Could you take a look at the last commit?

Now that we know that that Scala 2 symbol did not have a position we should check why that was the case. Maybe there is a bug somewhere else and this is only hiding it.

@pikinier20 pikinier20 force-pushed the extension-method-doc-new-heuristic branch from 87eea93 to 6cdc381 Compare June 9, 2022 13:25
@rochala rochala removed the request for review from smarter August 19, 2022 07:47
def ffffff[B](b: B): (A, B) = ???
extension (using String)(using Unit)(a: Animal)(using Int)(using Number)
def f11(b: Any)(c: Any): Any
= ???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these tests work? I see test “fixtures” but no test specification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had answered in person, but I'll put it here for posterity:
This works by comparing the text of the file with the output of scala-meta, similarly to what is done in the compiler with the tests/pos, tests/neg folders.
This is therefore both the declaration and the specification for the tests !

@julienrf julienrf requested a review from pikinier20 August 24, 2022 09:00
@julienrf
Copy link
Contributor

@pikinier20, I’ve re-requested a review from you because the content of the PR changed since your previous review.

Sporarum added a commit to Sporarum/dotty that referenced this pull request Aug 24, 2022
Duplicate of scala#14810, once merged, frop this
@Sporarum
Copy link
Contributor

Sporarum commented Dec 2, 2022

Hello,
this PR seems very close to being mergeable, since @pikinier20 seems unavailable, could someone else re-review it so we can move things forward?

@prolativ
Copy link
Contributor

prolativ commented Dec 2, 2022

@szymon-rd @Florian3k

Sporarum added a commit to Sporarum/dotty that referenced this pull request Dec 13, 2022
Duplicate of scala#14810, once merged, frop this
@Sporarum
Copy link
Contributor

Hello,
@szymon-rd, @Florian3k, have you forgotten to review this PR ?

@Sporarum Sporarum requested review from Florian3k and szymon-rd and removed request for pikinier20 December 20, 2022 15:36
Copy link
Contributor

@szymon-rd szymon-rd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, but @Florian3k has the most expertise there right now.

@julienrf julienrf assigned prolativ and unassigned pikinier20 Jan 3, 2023
@prolativ prolativ assigned Florian3k and unassigned prolativ Jan 3, 2023
Copy link
Contributor

@Florian3k Florian3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. (But please note that I'm in no way expert on this part of codebase)

P.S. Sorry for the delay, something was wrong with my github notifications. Should be working fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants